package insertData;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class BatchInsertExample {
    public static void batchInsertData(Connection connection) throws SQLException {
        String insertQuery = "INSERT INTO uf_t1 (name, email) VALUES (?, ?)";
        try (PreparedStatement preparedStatement = connection.prepareStatement(insertQuery)) {
            for (int i = 0; i < 100; i++) {
                preparedStatement.setString(1, "User" + i);
                preparedStatement.setString(2, "user" + i + "@example.com");
                preparedStatement.addBatch(); // Add the current row to the batch
            }
            preparedStatement.executeBatch(); // Execute the batch
        }
    }
}
